<template>
	<view class="order-manage">
		<!-- 顶部搜索及筛选区域 -->
		<view class="top-bar">
			<view class="cardform">
				<u--form labelPosition="left" :model="card" ref="uForm">
					<u-form-item label="优惠券名称" prop="card.name" borderBottom ref="item1" labelWidth="200rpx">
						<u--input placeholder="请输入内容" border="surround" v-model="card.name"
							style="border-radius: 40rpx;"></u--input>
					</u-form-item>
					<u-form-item label="优惠券类型" prop="card.type" borderBottom ref="item1" labelWidth="200rpx">
						<u-radio-group v-model="card.type" placement="row" style="gap: 85rpx;">
							<u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in radiolist1" :key="index" :label="item.name" :name="item.name">
							</u-radio>
						</u-radio-group>
					</u-form-item>
					<u-form-item  borderBottom ref="item1" labelWidth="200rpx" v-if="card.type=='满减券'">
						满<u--input v-model="card.triggerMoney" border="none" style="width: 200rpx;color: forestgreen;font-weight: bold;"></u--input>元减
						<u--input v-model="card.preferentialMoney" border="none" style="width: 200rpx;color: forestgreen;font-weight: bold;"></u--input>元
					</u-form-item>
					<u-form-item borderBottom ref="item1" labelWidth="200rpx" v-if="card.type=='打折券'">
						打<u--input v-model="card.discount" border="none" style="width: 200rpx;"></u--input><view>折</view>
					</u-form-item>
					<u-form-item label="发放开始时间" prop="card.start" borderBottom ref="item1" labelWidth="200rpx">
						<uni-datetime-picker type="date" v-model="card.start"></uni-datetime-picker>
					</u-form-item>
					<u-form-item label="发放结束时间" prop="card.end" borderBottom ref="item1" labelWidth="200rpx">
						<uni-datetime-picker type="date" v-model="card.end"
							:start="card.start"></uni-datetime-picker>
					</u-form-item>
					<u-form-item label="投放数量" prop="card.num" borderBottom ref="item1" labelWidth="200rpx">
						<u--input border="surround" v-model="card.num"
							style="border-radius: 40rpx;width: 100rpx; height: 40rpx;"></u--input>
						<view style="width: 300rpx;margin-left: 20rpx;">张</view>
					</u-form-item>
<!-- 					<u-form-item label="每人限额" prop="card.limit" borderBottom ref="item1" labelWidth="200rpx"> -->
<!-- 						<u--input border="surround" v-model="card.limit"
							style="border-radius: 40rpx;width: 100rpx; height: 40rpx;"></u--input>
						<view style="width: 300rpx;margin-left: 20rpx;">张</view>
					</u-form-item> -->
					<u-form-item label="使用期限" borderBottom ref="item1" labelWidth="200rpx">
						<uni-datetime-picker type="date" v-model="card.expirationStart"></uni-datetime-picker>
						
					</u-form-item>
					<u-form-item label="使用期限" borderBottom ref="item1" labelWidth="200rpx">
						<uni-datetime-picker type="date" v-model="card.expirationEnd" :start="card.expirationStart"></uni-datetime-picker>
					</u-form-item>
				</u--form>
			</view>
			<view>
				<button class="detail-btn" @click="getcard()">
					确认投放
				</button>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		get,
		post,
		put
	} from '../../utils/request.js'
	export default {
		data() {
			return {
				// card: {},
				radiolist1: [{
						name: '满减券',
						disabled: '满减券'
					},
					{
						name: '打折券',
						disabled: '打折券'
					}
				],
				card:{
					name:'',
					type:'',
					discount:'',
					triggerMoney:'',
					preferentialMoney:'',
					start:'',
					end:'',
					num:'',
					size:0,
					expirationStart:'',
					expirationEnd:'',
					status:0
				}
			}
		},
		methods: {
			async getcard() {
				this.card.mId=uni.getStorageSync('merchant').id
				console.log(this.card)
				await post('/dev-api/system/coupon',this.card)
			}
		}
	}
</script>

<style>
	.order-manage {
		background-color: #f5f5f5;
		min-height: 100vh;
		/*  padding: 10px; */
	}

	/* 顶部搜索及筛选 */
	.top-bar {
		padding: 10px;
		background-color: #2979ff;
		height: 200rpx;
	}

	.cardform {
		width: 90%;
		padding-left: 5%;
		padding-right: 5%;
		height: 900rpx;
		background-color: white;
		border-radius: 15rpx;
	}

	.detail-btn {
		background-color: #2979ff;
		width: 400rpx;
		color: white;
		border-radius: 45rpx;
		margin-top: 40rpx;
	}
</style>